#include "player.h"


void CPlayer::FireWeapon()
{
	

	// use camera->lookAt vector and multiply
	// this lookAt vector by the ammo's speed
	// to get the ammo velocity vector.
	// create the new ammo and attach it to
	// the world. fire the ammo
	

	if(gun==1)//rocket
	{
		CRocket *newRocket = new CRocket;
		newRocket->pitch = camera->pitch;
		newRocket->direction = direction;
		newRocket->position = position;
		newRocket->forward = camera->lookAt.UnitVector();
		newRocket->SetAudioSystem(audioSys);
		audioSys->PlaySoundDX(audioSys->iThunk);
		newRocket->LoadAudio(audioSys->iExplode);
		newRocket->AttachTo(terrain);
	}else if(gun==2){//bfg9000
		CBFG *newRocket = new CBFG;
		newRocket->pitch = camera->pitch;
		newRocket->direction = direction;
		newRocket->position = position;
		newRocket->forward = camera->lookAt.UnitVector();
		newRocket->SetAudioSystem(audioSys);
		audioSys->PlaySoundDX(audioSys->iThunk);
		newRocket->LoadAudio(audioSys->iExplode);
		newRocket->AttachTo(terrain);
	}else{//sniper
		CSNIPER *newRocket = new CSNIPER;
		newRocket->pitch = camera->pitch;
		newRocket->direction = direction;
		newRocket->position = position;
		newRocket->forward = camera->lookAt.UnitVector();
		newRocket->SetAudioSystem(audioSys);
		audioSys->PlaySoundDX(audioSys->iLaser2);
		newRocket->LoadAudio(audioSys->iExplode);
		newRocket->AttachTo(terrain);
	}
}